from rest_framework.fields import SerializerMethodField
from rest_framework.serializers import ModelSerializer, SerializerMetaclass

from order.models import CouponModel, UserCouponModel, OrderModel, OrderDatailModel, goumai


class CouponSer(ModelSerializer):
    class Meta:
        model=CouponModel
        fields= '__all__'

class UserCouponSer(ModelSerializer):
    coupon=CouponSer(read_only=True)
    class Meta:
        model=UserCouponModel
        fields='__all__'



class OrderSercc(ModelSerializer):
    class Meta:
        model=OrderDatailModel
        fields=("coursename","courseid","order","coursename","cover")

class OrderSer(ModelSerializer):
    orderdatailmodel_set=OrderSercc(read_only=True,many=True)
    class Meta:
        model=OrderModel
        fields='__all__'

class UserOrderSer(ModelSerializer):
    class Meta:
        model=OrderDatailModel
        fields='__all__'

class GouwuSer(ModelSerializer):
    class Meta:
        model=goumai
        fields='__all__'
